package coop.bancocredicoop.proyectos.gd;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

import coop.bancocredicoop.proyectos.gd.fileListing.DocumentBrowser;

public class DocumentFile implements SourceDocument {

    private String baseDir;
    private String fileName;

    public DocumentFile(String baseDir, String fileName) {
        this.baseDir = baseDir;
        this.fileName = fileName;
    }

    private String getFullPath() {
    	return String.format("%s/%s", baseDir, fileName);
    }

    public InputStream getInputStream() throws FileNotFoundException {
    	InputStream inputStream = new FileInputStream(getFullPath());
    	return inputStream;
    }

    public String getOriginalFilename() {
    	return fileName;
    }

    public File getFile() {
    	return new File(getFullPath());
    }

	public void documentCreated(DocumentBrowser documentBrowser) {
		documentBrowser.documentCreated(this);
	}
	
}
